﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

using NUnit.Framework;
using DbSharp.Framework.CaseFile.Parser;
using DbSharp.Framework.CaseFile;
using DbSharp.Framework;

namespace UnitTestProject.CaseFile
{
    [TestFixture]
    public class PerfTestCaseExtractTest
    {
        [Test]
        public void ExtractTestCases()
        {
            string testCaseFile = @"CaseFileSample\TestCase_V2_PerfTest_2Test.xml";
            CaseFileNavigator fileNavigator=new CaseFileNavigator(testCaseFile) ;

            DbConnectionConfigExtractor dbConnExtractor = new DbConnectionConfigExtractor(testCaseFile, fileNavigator.SelectGlobalSetting());
            ProcedureDeclarationExtractor procExtractor=new ProcedureDeclarationExtractor(fileNavigator.SelectProcDeclsRoot(),dbConnExtractor) ;
            CaseFileParser parser = new CaseFileParser(null, testCaseFile);
            PerfTestCaseExtractor caseExtractor = new PerfTestCaseExtractor(parser.ListStatement, fileNavigator.SelectPerfTestCasesRoot(), fileNavigator.SelectGlobalSetting());
            Assert.AreEqual(2, caseExtractor.ListCase.Count);
        }

        [Test]
        public void TestExtractorIndex()
        {
            string testCaseFile = @"CaseFileSample\TestCase_V2_PerfTest_2Test.xml";
            CaseFileNavigator fileNavigator = new CaseFileNavigator(testCaseFile);

            DbConnectionConfigExtractor dbConnExtractor = new DbConnectionConfigExtractor(testCaseFile, fileNavigator.SelectGlobalSetting());
            CaseFileParser parser = new CaseFileParser(null, testCaseFile);
            PerfTestCaseExtractor caseExtractor = new PerfTestCaseExtractor(parser.ListStatement, fileNavigator.SelectPerfTestCasesRoot(), fileNavigator.SelectGlobalSetting());
            PerformanceTestCase testCase = caseExtractor["Perf_Test2"];
            Assert.IsNotNull(testCase);
        }

    }
}
